using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Drawing;
using OpenTK.Math;

namespace Dogfight2008.Common.Tests
{
  [TestFixture]
  public class CplLoaderFixture
  {
    [Test]
    public void EmptyString()
    {
      ColoredPolygonMesh mesh = CplLoader.FromString();
      Assert.AreEqual(0, mesh.Polygons.Count);
    }

    Vector3 v(double x, double y, double z)
    {
      return new Vector3((float)x, (float)y, (float)z);
    }

    [Test]
    public void SingleYellowTriangle()
    {
      ColoredPolygon pol = new ColoredPolygon(Color.Yellow,
        v(0, 1, 2),
        v(3, 4, 5),
        v(600, 7, 8));
      ColoredPolygonMesh expected = new ColoredPolygonMesh(pol);
      string repr = @"cpl
vertices 3
polygons 1
---8<---
0 1 2
3 4 5
600 7 8
3 255 255 0 0 1 2
";
      ColoredPolygonMesh result = CplLoader.FromString(repr);
      Assert.AreEqual(expected, result);
    }
  }
}
